package de.cbf.cam.dsa.entity.edit.item.handler;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;

import de.cbf.cam.dsa.entity.edit.item.act.ActivatorEditEntityItem;
import de.cbf.logview.views.LogView;

/**
 * Our sample handler extends AbstractHandler, an IHandler base class.
 * @see org.eclipse.core.commands.IHandler
 * @see org.eclipse.core.commands.AbstractHandler
 */
public class OpenLogViewHandler extends AbstractHandler {
	/**
	 * The constructor.
	 */
	public OpenLogViewHandler() {
	}

	/**
	 * the command has been executed, so extract extract the needed information
	 * from the application context.
	 */
	public Object execute(ExecutionEvent event) throws ExecutionException {
		try {			
			IWorkbench workbench = ActivatorEditEntityItem.getDefault().getWorkbench();
			IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
			IWorkbenchPage page = window.getActivePage();
//			IViewPart part = 
			page.showView(LogView.ID,ActivatorEditEntityItem.LOG_VIEW_ITEM_EDIT_SEC_ID,IWorkbenchPage.VIEW_ACTIVATE);			
//			part.getViewSite().getSecondaryId();
		} catch (PartInitException e) {
			throw new ExecutionException("",e);
		}
		return null;
	}
}
